<?php
class libevent
{
	public function __construct()
	{
		$this->CI	= &get_instance();
		$this->CI->load->model("events");
	}
	
	//事件更新
	public function updateEvent($eventId, $row)
	{
		return $this->CI->events->modifyEventById($eventId, $row);
	}
	
	/**
	 * 事件处理时，追加工作纪录
	 
	public function appendEventRecord($eventId, $row)
	{
		$ret['event_records']	= $row['raw_record'] 
								. "\n------------".$row['username']." ". date('Y-m-d H:i:s')."---------\n"
								. $row['event_records']
								."\n-------------------------------------\n";
		return $this->CI->events->modifyEventById($eventId, $ret);								
	}
	*/
	/**
	 * 事件转发
	 */
	public function forwardEvent($eventId, $username, $row)
	{
		$ret	= $this->CI->events->getEventById($eventId, 'event_records');
		
		$row['event_records']	= $ret['event_records']
								. $username . " " . date('Y-m-d H:i:s') . " 添加了工作说明:\n"
								. $row['event_records'] 
								. "\n---------------------------------------\n";
		return $this->CI->events->modifyEventById($eventId, $row);
	}
	
	/**
	 * 工作纪录追加
	 */
	public function appendEventRecord($eventId, $username, $datetime, $work_record)
	{
		$row			= $this->CI->events->getEventById($eventId, 'event_records');
		$work_record	= $row['event_records']
						. $username . " " . $datetime . $work_record 
						. "\n---------------------------------------\n";
		return $this->CI->events->modifyEventById($eventId, array('event_records'=>$work_record));
	}
	
	public function appendEventDesc($eventId, $username, $datetime, $append_desc)
	{
		$row			= $this->CI->events->getEventById($eventId, 'event_desc');
		$event_desc		= $row['event_desc']
						.= $username . " " . $datetime . " ".$append_desc
						. "\n---------------------------------------\n";
		return $this->CI->events->modifyEventById($eventId, array('event_desc' => $append_desc));
	}
}